package com.example.wowangz.rabbitmq.send;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.wowangz.modules.user.model.User;

@Service("queueSenderService")
public class QueueSenderService {

	@Autowired
	private RabbitTemplate rabbitTemplate;

	public void sendMsgToQueueOne(String msgOne) {
		System.out.println("queue_one sender : " + msgOne);
		rabbitTemplate.convertAndSend("queue_one", msgOne);
	}

	public void sendMsgToQueueTwo(User user) {
		System.out.println("queue_two sender : " + user);
		// mq发送的对象必须序列化即实现Serializable
		rabbitTemplate.convertAndSend("queue_two", user);
	}

}
